<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-gatewayAttrConfig-edit" th:object="${gatewayAttrConfig}">
        <input id="id" name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">service_id：</label>
            <div class="col-sm-8">
                <input id="serviceId" name="serviceId" th:field="*{serviceId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">配置类型：</label>
            <div class="col-sm-8">
                <div class="input-group" style="width: 100%">
                    <select name="type" class="form-control m-b"
                            th:with="type=${@dict.getType('sys_gatewayattr_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                th:field="*{type}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">谓词名称：</label>
            <div class="col-sm-8">
                <input id="attrName" name="attrName" th:field="*{attrName}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">属性附属参数(json)：</label>
            <div class="col-sm-8">
                <input id="attrArgs" name="attrArgs" th:field="*{attrArgs}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <input id="desc" name="desc" th:field="*{desc}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">排序：</label>
            <div class="col-sm-8">
                <input id="sort" name="sort" th:field="*{sort}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="onoffswitch">
                    <input type="checkbox" th:checked="${gatewayAttrConfig.state == 1 ? true : false}"
                           class="onoffswitch-checkbox" id="attr-state">
                    <label class="onoffswitch-label" for="attr-state">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
                </div>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/gatewayAttrConfig";
    $("#form-gatewayAttrConfig-edit").validate({
        rules: {
            xxxx: {
                required: true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $('#form-gatewayAttrConfig-edit').serializeArray();
            var state = $("input[id='attr-state']").is(':checked') == true ? 1 : 0;
            data.push({"name": "state", "value": state});
            $.operate.save(prefix + "/edit", data);
        }
    }
</script>
</body>
</html>
